package com.shuai.blog.common;

import lombok.Data;

@Data
public class HttpResult {
    private int code;
    private String msg;
    private Object data;

    public static HttpResult success(Object data) {
        HttpResult httpResult = new HttpResult();
        httpResult.setCode(200);
        httpResult.setMsg("");
        httpResult.setData(data);
        return httpResult;
    }

    public static HttpResult success(int code, Object data) {
        HttpResult httpResult = new HttpResult();
        httpResult.setCode(code);
        httpResult.setMsg("");
        httpResult.setData(data);
        return httpResult;
    }

    public static HttpResult success(int code, String msg, Object data) {
        HttpResult httpResult = new HttpResult();
        httpResult.setCode(code);
        httpResult.setMsg(msg);
        httpResult.setData(data);
        return httpResult;
    }

    public static HttpResult fail(String msg) {
        HttpResult httpResult = new HttpResult();
        httpResult.setCode(-1);
        httpResult.setMsg(msg);
        httpResult.setData(null);
        return httpResult;
    }

    public static HttpResult fail(int code, String msg) {
        HttpResult httpResult = new HttpResult();
        httpResult.setCode(code);
        httpResult.setMsg(msg);
        httpResult.setData(null);
        return httpResult;
    }

    public static HttpResult fail(int code, String msg, Object data) {
        HttpResult httpResult = new HttpResult();
        httpResult.setCode(-1);
        httpResult.setMsg(msg);
        httpResult.setData(data);
        return httpResult;
    }


}
